from selenium.webdriver.common.by import By

from base.page_base import BasePage


class BackLoginPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.username = (By.ID, "username")
        self.password = (By.ID, "password")
        self.code = (By.ID, "valicode")
        self.submit = (By.XPATH, '//*[@id="loginForm"]/div[4]/input')
        self.success = (By.XPATH, "/html/body/div[1]/div[3]/ul/li[2]/a/span/div")

    def back_login(self, username, password, code="8888"):
        self.base_input(self.username, username)
        self.base_input(self.password, password)
        self.base_input(self.code, code)
        self.base_click(self.submit)

    def get_success_result(self):
        result = self.fd_element(self.success).text
        return result
